package com.study.thread;

import java.util.concurrent.TimeUnit;

class Phone {
    protected synchronized void sendSms() {
        System.out.println(" sendSms ");
    }

    protected synchronized void sendEmail() {
        System.out.println(" sendEmail ");
    }
}

public class SimpleFunctionSynchronized {
    public static void main(String[] args) {
        Phone phone = new Phone();
        new Thread(()->{
            try {
                TimeUnit.SECONDS.sleep(3);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            phone.sendEmail();
        }).start();

        new Thread(()->{
            phone.sendSms();
        }).start();

    }
}
